package com.ds.common.org.expression.org;

import java.util.List;
import java.util.Stack;

import com.ds.common.expression.ParseException;
import com.ds.common.expression.function.Function;
import com.ds.org.Org;
import com.ds.org.OrgManager;
import com.ds.server.OrgManagerFactory;

/**
 * <p>Title: JDSORG组织机构中间件</p>
 * <p>Description: </p>
 * <p>Copyright: jds Copyright (c) 2003-2008</p>
 * <p>Company: www.justdos.net</p>
 *
 * @author wenzhangli
 * @version 2.0
 */
public class GetAllOrg extends Function {

    public GetAllOrg() {
        numberOfParameters = 0;
    }

    public void run(Stack stack) throws ParseException {
        checkStack(stack); // check the stack

    }

    protected Org[] perform() throws ParseException {
        OrgManager orgManager = OrgManagerFactory.getOrgManager();

        List<Org> result = orgManager.getOrgs();
        return (Org[]) result.toArray(new Org[result.size()]);
    }
}
